<div id="comment-container" class="container">
    <div id="msg-container">
        <h2 class="error-tips"></h2>
    </div>
    <switch name="result.type">
    <case value="Q"><h2><a href="{$result.question_id|format_question_url=$result['title']}">{$result.title|Input::forShow}</a></h2></case>
    <case value="A"><p class="content">{$result.details|parse_markup=$result['markup_mode']}</p></case>
    </switch>
    <form id="comment-form" method="POST" action="{:U('Comment/add')}">
    	<input id="type" type="hidden" name="type" value="{$result.type}" />
    	<input id="rid" type="hidden" name="rid" value="{$result.related_id}" />
        <textarea id="comment-details" class="textarea" name="details" rows="5" cols="90"></textarea>
        <p id="comment-counter" class="counter"></p>
        <eq name="captcha" value="1">
        <div class="captcha-container">
            <label for="verify">{$Think.lang.captcha}:</label><input id="verify" class="input verify" type="text" name="verify" value="" />
            <img class="captcha" src="{:U('Ajax/captcha')}" title="{$Think.lang.captcha_again}" onclick="reCaptcha(this);" />
        </div>
        </eq>
        <p><input id="comment-submit" class="button" type="submit" value="{$Think.lang.post_comment}" /></p>
    </form>
</div>

<load href="__PUBLIC__/Js/jquery.artTxtCount.js" />
<script type="text/javascript">
$(function(){
	
    $('#comment-details').artTxtCount($('#comment-counter'), 255);
    
    $('#comment-submit').click(function(){
        var url = $('#comment-form').attr('action');
        var redirect = $(location).attr('href');
        var data = {
            type: $('#type').val(),
            rid: $('#rid').val(),
            verify: $('#verify').val(),
            details: $('#comment-details').val()
        };
        $.post(url, data, function(json){
            $('#msg-container').show();
            var json = eval('('+json+')');
            if(json.status == 0){
                $('#msg-container>h2').html(json.info);
                return false;
            }else{
                $('#msg-container>h2').attr('class','success-tips').html(json.info);
                $('#comment-submit').attr({disabled:true, class:'alt-button'});
                setTimeout(function(){
                    window.location.href = redirect;
                }, WAIT_TIME);
            }
        });
        return false;
    });
});
</script>
